const { opendotaService } = require('../utils/request')

function getRecordByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/matches`
    }
  })
}

function getRecentRecordByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/recentMatches`
    }
  })
}

function getUserInfoByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}`
    }
  })
}

function getPeerByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/peers`
    }
  })
}

function getHero() {
  return opendotaService({
    url: '/',
    method: 'post',
    data: {
      url: `/heroes`
    }
  })
}

function getRanksByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/rankings`
    }
  })
}

function getHeroesByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/heroes`
    }
  })
}

function getTotalByUserId(userId, sort, limit = 10) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/matches?sort=${sort}&limit=${limit}`
    }
  })
}

function getWordcloudByUserId(userId) {
  return opendotaService({
    url: `/`,
    method: 'post',
    data: {
      url: `/players/${userId}/wordcloud`
    }
  })
}

module.exports = {
  getRecordByUserId,
  getRecentRecordByUserId,
  getUserInfoByUserId,
  getPeerByUserId,
  getHero,
  getRanksByUserId,
  getHeroesByUserId,
  getTotalByUserId,
  getWordcloudByUserId
}